//
// Created by luolijun on 2021/10/31.
//

#ifndef FACADE_H
#define FACADE_H

#include "falcon/model.h"
#include "falcon/styles.h"
#include "falcon/ui.h"

#include <cstdint>

namespace falcon {

struct Facade {
public:
    enum Scope : uint32_t {
        SCOPE_COMMON,    //  一些公共元素：注释、方框、等
        SCOPE_TYPE,      //  类：类、枚举、接口
        SCOPE_INSTANCE,  //  实例：组件
        SCOPE_STRUCTURE, //  结构关系：包
        SCOPE_BEHAVE,    //  行为
    };

    virtual ~Facade() = default;
    virtual int32_t id() const = 0;
    virtual uint32_t scope() const = 0;
    virtual const falcon::Object* object() const = 0;
    virtual const falcon::Styles* styles() const = 0;
    virtual falcon::Object* object() = 0;
    virtual falcon::Styles* styles() = 0;
    virtual falcon::SIZE size() const = 0;
    virtual void size(const falcon::SIZE& sz) = 0;
    virtual falcon::POINT place() const = 0;
    virtual void place(const falcon::POINT& cpos) = 0;
    virtual void draw(falcon::Painter& canvas) = 0;
    virtual Facade* clone() const = 0;
};

struct FacadePrototypeRepo {
    virtual ~FacadePrototypeRepo() = default;
    virtual int32_t registerPrototype(std::string groupName, Facade* fc) = 0;
    virtual void enumPrototypeGroup(std::function<int(std::string groupName)> callback) = 0;
    virtual void enumPrototype(std::string groupName, std::function<int(Facade* fc)> callback) = 0;
    virtual Facade* clonePrototype(int32_t tmplId, std::string name, int32_t id) = 0;
};

struct FacadePrototypeProvider {
    virtual ~FacadePrototypeProvider() = default;
    virtual void Setup(FacadePrototypeRepo& repo) = 0;
};

extern FacadePrototypeRepo* CreateFacadeRepo();
extern int LoadBuiltinPrototypes(FacadePrototypeRepo* repo);

} // namespace falcon
#endif // FACADE_H
